# 定义目标路径
TARGET_DIR=~/.scheduler

# 提示信息
echo "Installing .scheduler to $TARGET_DIR ..."

# 创建目标目录
mkdir -p "$TARGET_DIR"

# 解压归档文件到目标目录
tail -n +$(awk '/^__ARCHIVE_BELOW__/ {print NR + 1; exit 0; }' "$0") "$0" | tar -xz -C "$TARGET_DIR"

# 获取当前SHELL类型
CURRENT_SHELL=$(basename "$(ps -p $$ -o comm=)")
# 设置环境变量
if [ "$CURRENT_SHELL" = "zsh" ]; then
    echo "export PATH=\$PATH:$TARGET_DIR" >> ~/.zshrc
else
    echo "export PATH=\$PATH:$TARGET_DIR" >> ~/.bashrc
fi

# 提示完成
echo "Installation complete."

# 防止脚本被继续执行
exit 0

__ARCHIVE_BELOW__
